import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class UsePool {
    public static void main(String[] args) {
        //创建数量固定为5的线程池
        ExecutorService service = Executors.newFixedThreadPool(5);
        for (int i = 0; i < 5000; i++) {
            int n = 0;
            service.submit(new Runnable() {
                @Override
                public void run() {
                    //获取并打印添加的任务线程
                    System.out.println("线程为: "+Thread.currentThread().getName());
                }
            });
        }
    }
}
